#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e6+100;
typedef int LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
char str1[maxn],str2[maxn];
LL d[maxn],n,m,ans;
void pre(){
     int i=1;int j=0;
     while(i<m){
         if(str2[i]==str2[j]){
            d[i++]=++j;
         }
         else{
            if(j) j=d[j-1];
            else i++;
         }
     }
}
inline int solve(){
     n=strlen(str1);
     m=strlen(str2);
     memset(d,0,m*sizeof(LL));
     pre();
     int i=0;int j=0;
     ans=0;
     while(i<n){
        if(str1[i]==str2[j]){
            i++;j++;
            if(j==m){
                ans++;
                j=d[j-1];
            }
        }
        else{
            if(j) j=d[j-1];
            else i++;
        }
     }
     return ans;
}
int main(void){
   	cin.tie(0);std::ios::sync_with_stdio(false);
    LL t;cin>>t;
    while(t--){
        cin>>str2;
        cin>>str1;
        solve();
        cout<<ans<<endl;
    }
   	return 0;
}
